<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
/* Xử lý hệ thống route */
View::composer(array("default.blocks.header","default.xettuyen.pages.index"),"Composer");

Route::get('/',array("before"=>"auth",'as'=>'default_home','uses'=>'home\TuyenSinhController@getTuyenSinh'));
// Phần module auth
Route::group(array('prefix'=>'auth/'),function(){
	// Đăng Ký
	Route::get('dang-ky',array('before'=>'is_login','as'=>'auth.get.dangky','uses'=>'auth\AuthController@getDangky'));
	Route::post('dang-ky',array('before'=>'is_login','as'=>'auth.post.dangky','uses'=>'auth\AuthController@postDangky'));
	// login
	Route::get('login',array('before'=>'is_login','as'=>'auth.get.login','uses'=>'auth\AuthController@getLogin'));
	Route::post('login',array('before'=>'is_login','as'=>'auth.post.login','uses'=>'auth\AuthController@postLogin'));
	/* Forgot password */
	Route::get("forgot",array("as"=>"auth.get.forgot","before"=>"is_login","uses"=>"auth\AuthController@getforgot"));
	Route::post("forgot",array("as"=>"auth.post.forgot","before"=>"is_login","uses"=>"auth\AuthController@postforgot"));
	Route::get("active/{user}/{code}",array("as"=>"auth.get.active","before"=>"is_login","uses"=>"auth\AuthController@getReset"))->where(array('user'=>'[a-zA-Z0-9._@\-]+','code'=>'[a-zA-Z0-9._\-]+'));
	Route::post("reset",array("as"=>"auth.post.reset","before"=>"is_login","uses"=>"auth\AuthController@postReset"));
	// Logout
	Route::get('dang-xuat',array('as'=>'auth.get.logout','uses'=>'auth\AuthController@getLogout'));
});
// Phần module home
Route::group(array("before"=>"auth",'prefix'=>'tuyen-sinh/'),function(){
	Route::get('/',array('as'=>'tuyensinh.get.index','uses'=>'home\TuyenSinhController@getTuyenSinh'));
	Route::post('/',array('as'=>'tuyensinh.post.index','uses'=>'home\TuyenSinhController@postTuyenSinh'));
	Route::get('rut-ho-so',array('as'=>'tuyensinh.get.ruthoso','uses'=>'home\TuyenSinhController@getRuthoso'));
	Route::post('rut-ho-so',array('as'=>'tuyensinh.post.ruthoso','uses'=>'home\TuyenSinhController@getRuthoso'));
	Route::get('sua-ho-so',array('as'=>'tuyensinh.get.suahoso','uses'=>'home\TuyenSinhController@getSuahoso'));
	Route::post('sua-ho-so',array('as'=>'tuyensinh.post.suahoso','uses'=>'home\TuyenSinhController@postSuahoso'));
});
// Ajax
Route::group(array("before"=>"auth",'prefix'=>'ajax/'),function(){
	Route::post('load-quan-huyen',array('as'=>'ajax.post.quanhuyen','uses'=>'home\AjaxController@loadQuanHuyenByTinh'));
	Route::post('load-truong-trung-hoc-pho-thong',array('as'=>'ajax.post.thpt','uses'=>'home\AjaxController@loadTruongTHPTByTinh'));
	Route::post('load-name-khoi-xet',array('as'=>'ajax.post.khoixet','uses'=>'home\AjaxController@loadNameKhoiXet'));
	// Xử lý ngành nghề load
	Route::post('load-nganh-nghe',array('as'=>'ajax.post.nganhnghe','uses'=>'home\AjaxController@loadNganhNgheByNganh'));
	Route::post('check-dau-rot',array('as'=>'ajax.post.daurot','uses'=>'home\AjaxController@daurot'));
});
Route::get('check',function(){
	
	$nganh = NganhNghe::select('MaNganh')->where('idNganh','=',1)->get()->first();
	echo $nganh->MaNganh;
	echo "<pre>";
	print_r($nganh);
});
